<script setup lang="ts">
import type { EaArea } from './type'

const baseApi = '/ea/ea-area'

const { loadData, loading, model } = useDetail<EaArea>(baseApi)

defineExpose({ init: loadData })
</script>

<template>
  <el-empty v-if="!Object.keys(model).length" v-loading="loading" />
  <el-descriptions v-else v-loading="loading" :column="2" border>
    <el-descriptions-item label="上级" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.parentIdLabel }}
      </span>
    </el-descriptions-item>
    <el-descriptions-item label="城市名称" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.name }}
      </span>
    </el-descriptions-item>
    <el-descriptions-item label="城市编号" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.cityCode }}
      </span>
    </el-descriptions-item>
    <el-descriptions-item label="父级地理编号" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.parentCode }}
      </span>
    </el-descriptions-item>
    <el-descriptions-item label="地理编号" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.placeCode }}
      </span>
    </el-descriptions-item>
    <el-descriptions-item label="经度" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.lng }}
      </span>
    </el-descriptions-item>
    <el-descriptions-item label="纬度" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.lat }}
      </span>
    </el-descriptions-item>
    <el-descriptions-item label="排序号" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.sort }}
      </span>
    </el-descriptions-item>
    <el-descriptions-item label="备注" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.remark }}
      </span>
    </el-descriptions-item>
    <el-descriptions-item label="城市级别" label-class-name="item-label" label-align="right">
      <el-tag v-if="model.levelLabel" :color="model.levelLabel.ext?.color" effect="dark" type="info">
        {{ model.levelLabel?.label }}
      </el-tag>
    </el-descriptions-item>
  </el-descriptions>
</template>

<style scoped lang="scss">
.el-descriptions {
  :deep(.el-descriptions__header) {
    margin: 0 10px 12px;
  }

  :deep(.item-label) {
    width: 120px;
  }
}
</style>
